//package com.sse.product.handler;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
//import org.springframework.web.util.UriComponentsBuilder;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * @ClassName GatewayLogoutSuccessHandler
// * @Description TODO
// * @Author junyongli
// * @Date 2022/7/1 9:43
// * @Version 1.0
// **/
//@Component
//@Slf4j
//public class ProductLogoutSuccessHandler implements LogoutSuccessHandler {
//
//    @Value("${passport.api.logout}")
//    private String logoutUrl;
//
//    @Value("${spring.security.oauth2.client.registration.passport.client-id}")
//    private String clientId;
//
//    @Value("${spring.security.login-page}")
//    private String redirectUri;
//
//    @Override
//    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
//        String rdURL;
//        if(redirectUri.startsWith("http"))
//            rdURL=redirectUri;
//        else
//            rdURL= ServletUriComponentsBuilder.fromContextPath(request)
//                    .path(redirectUri).build().toUriString();
//        String loURL = UriComponentsBuilder.fromUriString(logoutUrl)
//                .queryParam("client_id", clientId)
//                .queryParam("redirect_uri", rdURL)
//                .toUriString();
//        log.info("Passport Logout Url:" + loURL);
//        response.sendRedirect(loURL);
//    }
//}
